package com.ruoyi.system.mapper;

import java.util.List;

import com.ruoyi.system.domain.TbAppCatalog;
import com.ruoyi.system.domain.TbAppVersion;
import com.ruoyi.system.domain.vo.AppCatalogVersionInfo;
import com.ruoyi.system.domain.vo.TbAppCatlogAndVersionVO;
import com.ruoyi.system.domain.vo.TbAppVersionVO;
import io.swagger.v3.oas.annotations.media.Schema;
import org.apache.ibatis.annotations.Param;

/**
 * 应用版本信息Mapper接口
 *
 * @author ruoyi
 * @date 2025-07-23
 */
public interface TbAppVersionMapper {


    /**
     * 查询应用版本信息
     *
     * @param id 应用版本信息主键
     * @return 应用版本信息
     */
    public TbAppVersion selectTbAppVersionById(Long id);

    /**
     * 查询应用版本信息列表
     *
     * @param tbAppVersion 应用版本信息
     * @return 应用版本信息集合
     */
    public List<TbAppVersion> selectTbAppVersionList(TbAppVersion tbAppVersion);

    /**
     * 新增应用版本信息
     *
     * @param tbAppVersion 应用版本信息
     * @return 结果
     */
    public int insertTbAppVersion(TbAppVersion tbAppVersion);

    /**
     * 修改应用版本信息
     *
     * @param tbAppVersion 应用版本信息
     * @return 结果
     */
    public int updateTbAppVersion(TbAppVersion tbAppVersion);

    /**
     * 删除应用版本信息
     *
     * @param id 应用版本信息主键
     * @return 结果
     */
    public int deleteTbAppVersionById(Long id);

    /**
     * 批量删除应用版本信息
     *
     * @param ids 需要删除的数据主键集合
     * @return 结果
     */
    public int deleteTbAppVersionByIds(Long[] ids);




    Long selectTbDeviceSnBy(String packageVersioncode);

    List<TbAppCatlogAndVersionVO> selectTbAppCatalogAndVersionList(TbAppCatalog tbAppCatalog);

    List<TbAppVersion> selectByPackageNameAndVersionCodes(@Param("list") List<String> versionCodes);

    TbAppVersion selectTbAppVersionByPackageVersioncode(String packageVersioncode);

    TbAppVersion getAppVersionByPackageVersioncode(@Param("packageVersioncode") String versionCode, @Param("packageVersionnumber") String versionName, @Param("packageName") String packageName);

    List<TbAppVersionVO> selectTbAppVersionLis(TbAppVersion tbAppVersion);

    AppCatalogVersionInfo findAppVersionByFilePath(String filePath);

    void updateDownloadCount(Long id);

    void updateInstallDeviceCount(Long id);

    List<TbAppVersion> selectLastVersion(String packageName);

    List<TbAppVersion> selectLastVersions(String packageName);

    TbAppVersion selectByPackageUrl(@Param("packageUrl") String downloadToken);

    TbAppVersion selectTbAppVersionByVersionCodeAndVersionNumber(@Param("packageVersioncode") String packageVersioncode, @Param("packageVersionnumber") String packageVersionnumber);



    TbAppVersion selectDiffPackageByVersions(@Param("packageName") String packageName,
                                             @Param("oldpackageVersioncode") String oldpackageVersioncode,
                                             @Param("oldpackageVersionnumber") String oldpackageVersionnumber,
                                             @Param("newpackageVersioncode") String newpackageVersioncode,
                                             @Param("newpackageVersionnumber") String newpackageVersionnumber);

    TbAppVersion selectByPackageIdAndCode(@Param("packageId") Long packageId, @Param("packageVersioncode") String packageVersioncode, @Param("packageVersionnumber") String packageVersionnumber);

    TbAppVersion selectByPackageId(@Param("packageId") Long packageId);

    String selectByPackageNameByCondition(@Param("packageVersionnumber") String packageVersionnumber,@Param("packageVersioncode") String packageVersioncode,@Param("appName") String appName);

    String selectTbAppVersionByPackageVersioncodeAndpackageName(@Param("bundeleName") String bundeleName, @Param("packageVersionnumber") String appVersion, @Param("packageVersionnumber") String versionCode);

    TbAppVersion selectBYConditions(@Param("packageId") Long packageId, @Param("packageVersionnumber") String packageVersionnumber, @Param("packageVersioncode") String packageVersioncode);

    TbAppVersion selectTbAppVersionByPackageVersioncodes(@Param("packageVersioncode") String packageVersioncode, @Param("packageVersionnumber") String packageVersionnumber, @Param("packageame") String packageame);

    Long getPackageIdByPackageName(String packageName);

    TbAppVersion selectByPackageNameAndVersionCodeAndVersionnumber(@Param("packageName") String packageName, @Param("packageVersioncode") String versionCode, @Param("packageVersionnumber") String versionnumber);

    TbAppVersion selectTbAppVersionByIdAndVersionCodeAndNumber(@Param("packageId") Long packageId, @Param("packageVersioncode") String packageVersionCode, @Param("packageVersionnumber") String packageVersionNumber);

    TbAppVersion selectBypackageNameAndVersion(@Param("packageName") String bundleName
            , @Param("packageVersion") String appVersion, @Param("versionCode") String versionCode);

    String selectBYPackageName(String packageName);

    TbAppVersion selectByPackageNameAndCodeAndNum(@Param("packageName") String packageName, @Param("packageVersioncode") String packageVersioncode, @Param("packageVersionnumber") String packageVersionnumber);

    TbAppVersion selectByAppNameAndCodeAndNum(@Param("packageName") String bundleName,@Param("packageVersionnumber") String appVersion, @Param("packageVersioncode") String versionCode);
}
